package mytest;

/**
 * Created by thinkpad on 2015/1/18.
 */
public class ValueAndReference {
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ValueAndReference that = (ValueAndReference) o;

        if (i != that.i) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return i;
    }

    private int i;

    public ValueAndReference(int i) {
        this.i = i;
    }

    public void modifyI(ValueAndReference v) {
        v.i = 10;
    }

    public int getI() {
        return i;
    }

    public static void main(String[] args) {
        ValueAndReference v1 = new ValueAndReference(8);
        System.out.println("before modify v1.i: " + v1.getI());
        v1.modifyI(v1);
        System.out.println("after modify v1.i: " + v1.getI());
    }


}
